//Brian Goodacre

#include "command_line.h"

//Standard Menu for the Command Line Interface
void print_command_line_menu(){
	printf("\n----------------------------------------------------\n");
	printf("**Command Line Interface**\n");
	printf("Please select an option:\n");
	printf("1 - View Server's data\n");
	printf("2 - View a Computer's data\n");
	printf("3 - Edit Server's data (remote computer)\n");
	printf("4 - Edit a Computer's data\n");	
	printf("5 - Disconnect a Computer from the Internet\n");	
	printf("6 - Connect a Computer to the Internet\n");
	printf("7 - View Server's Log\n");
	printf("0 - Exit Simulation\n");
}

//when editting a computer's data
void print_command_edit_computer_data(int num_computers){
	printf("\t  0   - Randomize all computers' data\n");
	printf("\t[2,%d] - Randomize a specific computer's data\n",num_computers+1);
}

//further down selection for #2
void print_command_view_computer_data(int num_computers){
	printf("\t  0   - See all computers' data.\n");
	printf("\t[2,%d] - Choose a specific computer.\n",num_computers+1);
}

//further down selection for #2
void print_command_disconnect_menu(int num_computers, int connected_to_the_internet[]){
	printf("\t  0   - Disconnect all computers from the internet.\n");
	printf("\t[");
	int i; for(i=0;i<num_computers;i++){
		if(connected_to_the_internet[i]==1)
			printf("%d ",i+2);
	}
	printf("] - Choose a specific computer to disconnect.\n");
}

void print_command_connect_menu(int num_computers, int connected_to_the_internet[]){
	printf("\t  0   - Connect all computers to the internet.\n");
	printf("\t[");
	int i; for(i=0;i<num_computers;i++){
		if(connected_to_the_internet[i]==0)
			printf("%d ",i+2);
	}
	printf("] - Choose a specific computer to connect.\n");
}

//editting server's data
void print_command_edit_server_data(int num_computers){
	printf("\t  0  - Randomize all data on the server\n");
	printf("\t[2,%d]- Randomize a specific computer's data on the server\n",num_computers+1);
}

//tell the server to print its data in this format
//print the data stored in the server nicely
//how to call: "print_server_data(storage_matrix, num_computers);"
void print_server_data(int storage_matrix[][default_storage_array_size], int num_rows, int version_array[]){
	int i,j;
	for(i=0;i<num_rows;i++){
		printf("\t Computer %d(ver%d)[",i+2,version_array[i]);
		for(j=0;j<default_storage_array_size;j++){
			printf("%d",storage_matrix[i][j]);
			if(j==default_storage_array_size-1)
				printf("].\n");//print period and new line
			else
				printf(", ");//print the comma and space
		}
	}
}

//tell the computer to print its data
//it should print it this way, nicely
//how to call: "print_computer_data(storage_array, default_storage_array_size, MyProc);"
void print_computer_data(int storage_array[], int num_columns, int MyProc, int version){
	int j;
	printf("\tComputer %d(ver%d)[",MyProc,version);
	for(j=0;j<num_columns;j++){
			printf("%d",storage_array[j]);
			if(j==num_columns-1){
				printf("].\n");//print period and new line
			}
			else{
				printf(", ");//print the comma and space
			}
	}
}

